<template>
  <a-input v-bind="$attrs" @click="openFn" v-model:value="txtValue" :disabled="props.isAdd && isUpdate"
    placeholder="请选择部门">
    <template #suffix>
      <CloseCircleOutlined @click="clearFn" />

    </template>
  </a-input>
  <!--  <a-button type="primary" style="margin-top: 10px" v-if="props.isAdd&&isUpdate">添加人员</a-button>-->
  <Modal @register="registerModal" @success="handleSuccess" :mode="props.mode"></Modal>
</template>

<script lang="ts" setup>
import Modal from './Modal.vue';
import { useModal } from "@/components/Modal";
import { ref, computed, watch } from "vue";
import { useMessage } from "@/hooks/web/useMessage";
import { CloseCircleOutlined } from '@ant-design/icons-vue';

import { useUserStore } from '@/store/modules/user';
const userStore = useUserStore();


defineOptions({ name: 'Ainput' });
const props = defineProps({
  mode: { type: String, default: "multiple" },
  ids: { type: String, default: "" },
  isAdd: { type: Boolean, default: false },
  value: { type: String, default: "" },
});
const emit = defineEmits(['change', 'update:value', "success"]);
const [registerModal, { openModal }] = useModal();
const { createMessage } = useMessage();
//userStore.chatIsUpdate
const isUpdate = computed(() => { return userStore.chatIsUpdate });
const options = ref([])
// const txtValue = computed(() => { return props.value });
// const txtValue = ref("");
const txtValue = computed(() => { return props.value });

function openFn() {

  openModal(true, { ids: props.ids })
}

function clearFn(e) {
  // txtValue.value = {};
  let result = { deptId: "", title: "" };
  emit("success", result);
}


function handleSuccess(node) {
  emit("success", node)

}

</script>

<style scoped></style>
